from decimal import Decimal, ROUND_HALF_UP

from ttzScrapyProject.utils import MumberUtils, ModelUtils


class UserVo:
    """
        登录用户信息
        Nickname
        UserId
        coinBean
        costAmount
        isScrpay
        luckCount
        model
        modelData
        modelSnowballCount
        password
        phone
        snowballCount
        snowballtarget
        usertoken
        winAmount
    """

    # def __init__(self):
    #     self.currentSnowballParentIndex =0
    #     self.currentSnowballChildrenIndex=0

    def setStartHour(self, startHour):
        self.startHour = startHour

    def setEndHour(self, endHour):
        self.endHour = endHour

    def setTodayIsStart(self, todayIsStart):
        if todayIsStart == '1':
            self.todayIsStart = True
        else:
            self.todayIsStart = False

    # 是否交换卡片
    def setExchangeIsCard(self, exchangeIsCard):
        if exchangeIsCard == '1':
            self.exchangeIsCard = True
        else:
            self.exchangeIsCard = False

    # 交换卡片次数
    def setExchangeCardNum(self, exchangeCardNum):
        self.exchangeCardNum = int(exchangeCardNum)

    # 交换卡片频率,1d1次,3d1次,5d一次
    def setExchangeCardFrequency(self, exchangeCardFrequency):
        self.exchangeCardFrequency = exchangeCardFrequency

    """
        用户类型: 1下注,2爬虫
    """
    def setUserType(self,userType):
        self.userType = userType

    def setUserNoticeList(self, userNoticeList):
        self.userNoticeList = userNoticeList

    def setPhone(self, phone):
        self.phone = phone

    def setPassword(self, password):
        self.password = password

    def setUserToken(self, usertoken):
        self.usertoken = usertoken

    def setModel(self, model):
        self.model = model

    def setWinAmount(self, winAmount):
        self.winAmount = winAmount

    def setCostAmount(self, costAmount):
        self.costAmount = costAmount

    def setSnowballCount(self, snowballCount):
        self.snowballCount = snowballCount

    def setIdentity(self, identity):
        self.identity = identity

    def setIsScrpay(self, isScrpay):
        # 用户类型,1:爬虫;2非爬虫;3测试账号
        if isScrpay == '2':
            self.isScrpay = True
            self.setIdentity(False)
        else:
            self.isScrpay = False
            if isScrpay == '3':
                self.setIdentity(True)
            else:
                self.setIdentity(False)
        self.isScrpay = isScrpay


    def setSnowballtarget(self, snowballtarget):
        self.snowballtarget = snowballtarget

    def setModelData(self, modelData):
        self.modelData = modelData

    def setModelSnowballCount(self, modelSnowballCount):
        self.modelSnowballCount = modelSnowballCount

    def setLuckCount(self, luckCount):
        self.luckCount = luckCount

    def setCoinBean(self, coinBean):
        self.coinBean = coinBean

    def setNickname(self, Nickname):
        self.Nickname = Nickname

    def setUserId(self, UserId):
        self.UserId = UserId

    def setTodayWin(self, todayWin):
        self.TodayWin = todayWin

    # 今日止损目标
    def setTodayCost(self, todayCost):
        self.TodayCost = todayCost

    def setCurrentSnowballParentIndex(self, currentSnowballParentIndex):
        self.currentSnowballParentIndex = currentSnowballParentIndex

    def setCurrentSnowballChildrenIndex(self, currentSnowballChildrenIndex):
        self.currentSnowballChildrenIndex = currentSnowballChildrenIndex

    def setStop(self, stop):
        self.stop = stop

    def setArr(self, arr):
        self.arr = arr

    def setDetailDataId(self, detailDataId):
        self.detailDataId = detailDataId

    def setLuckNum(self, LuckNum):
        self.LuckNum = LuckNum

    def setCostSum(self, costSum):
        self.CostSum = costSum

    def setWinSum(self, winSum):
        self.WinSum = winSum

    def setCreateTime(self, createTime):
        self.CreateTime = createTime

    def setDiff(self, diff):
        self.diff = diff

    def setLotteryIssue(self, lotteryIssue):
        self.lotteryIssue = lotteryIssue

    def setLastLotteryIssue(self, lastLotteryIssue):
        self.lastlotteryIssue = lastLotteryIssue

    def setCountDownFuck(self, countDownFuck):
        self.countDownFuck = countDownFuck

    def setLotteryInfoList(self, lotteryInfoList):
        self.lotteryInfoList = lotteryInfoList

    def getPhone(self):
        return self.phone

    def getPassword(self):
        return self.password

    def getUserToken(self):
        return self.usertoken

    def getModel(self):
        return self.model

    def getWinAmount(self):
        return self.winAmount

    def getCostAmount(self):
        return self.costAmount

    def getSnowballCount(self):
        return self.snowballCount

    def getIsScrpay(self):
        return self.isScrpay

    def getSnowballtarget(self):
        return self.snowballtarget

    def getModelData(self):
        return self.modelData

    def getModelSnowballCount(self):
        return self.modelSnowballCount

    def getLuckCount(self):
        return self.luckCount

    def getCoinBean(self):
        return self.coinBean

    def getNickname(self):
        return self.Nickname

    def getUserId(self):
        return self.UserId

    def compare(self,userVo2):
        return (
                self.model == userVo2.model and
                #雪球模式轮数
                self.snowballCount == userVo2.snowballCount and
                #  每期雪球目标,小目标
                self.snowballtarget == userVo2.snowballtarget and
                # 爬虫启动时间(小时)
                self.startHour == userVo2.startHour and
                # 爬虫停止时间(小时)
                self.endHour == userVo2.endHour and
                #
                self.luckCount == userVo2.luckCount and
                # 今天盈利目标
                self.winAmount == userVo2.winAmount and
                # 今天止损目标
                self.costAmount == userVo2.costAmount and
                # 是否到达目标 前一轮和后一轮都到达了目标
                not (not self.stop and not userVo2.stop)
                )

if __name__ == '__main__':
    uservo = UserVo()
    uservo.model ="3N0"
    uservo.snowballCount = 1
    uservo.snowballtarget = 1
    uservo.startHour = 1
    uservo.endHour = 2
    uservo.luckCount = 1
    uservo.winAmount = 1
    uservo.costAmount = 1
    uservo.stop = False

    uservo1 = UserVo()
    uservo1.model ="3N0"
    uservo1.snowballCount = 1
    uservo1.snowballtarget = 1
    uservo1.startHour = 1
    uservo1.endHour = 2
    uservo1.luckCount = 1
    uservo1.winAmount = 1
    uservo1.costAmount = 1
    uservo1.stop = False

    print(uservo.compare(uservo1))
    userVoList = []
    userVoList.append(uservo)
    userVoList.append(uservo1)
    userVoList.append(uservo1)
    print(userVoList)
    del userVoList[0]
    print(userVoList)
